package action;

import controller.Action;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Curso;
import model.Disciplina;
import model.Professor;
import model.Turma;

public class EditarTurmaAction extends ManterTurmaAction {

    @Override
    public void setParametros(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try {
            request.setAttribute("editar", "readonly");
            request.setAttribute("excluir", "");
            
            int codTurma = Integer.parseInt(request.getParameter("codTurma"));
            Turma turma = Turma.obterTurma(codTurma);
            request.setAttribute("turma", turma);
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void efetuaPersistencia(Turma turma) throws ServletException {
        try {
            turma.alterar();
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

}
